#pragma once
#include "SehnsuchtPrecompiled.hxx"
#include "SehnsuchtRenderTargetBase.hxx"

namespace Sehnsucht
{
	class_decl BasicRenderTarget : public RenderTargetBase
	{
	private:

		// Device/Device Context

#if _Reign_desktop_support_window_7
		typedef ID3D11DeviceContext *Context3Ptr;
		typedef ID3D11Device *Device3;
#else
		typedef ID3D11DeviceContext1 *Context3Ptr;
		typedef ID3D11Device1 *Device3Ptr;
#endif

		/// Resource views
		Microsoft::WRL::ComPtr<ID3D11UnorderedAccessView> m_d3dUnorderedAccessView; // d3d uav
		Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_d3dShaderResourceView; // d3d srv

		/// Resources
		Microsoft::WRL::ComPtr<ID3D11Texture2D> m_d3dRenderTarget; // d3d rt
		Microsoft::WRL::ComPtr<ID3D11Texture2D> m_d3dDepthStencil; // d3d rt

		Context3Ptr m_d3dContext; // d3d
		Device3Ptr m_d3dDevice; // d3d

		float32 m_height;
		float32 m_width;

	public:

		REIGN_FORCEINLINING ID3D11UnorderedAccessView **GetWriteViewAddress() { return m_d3dUnorderedAccessView.GetAddressOf(); };
		REIGN_FORCEINLINING ID3D11ShaderResourceView **GetReadViewAddress() { return m_d3dShaderResourceView.GetAddressOf(); };
		REIGN_FORCEINLINING ID3D11UnorderedAccessView *GetWriteViewPtr() { return m_d3dUnorderedAccessView.Get(); };
		REIGN_FORCEINLINING ID3D11ShaderResourceView *GetReadViewPtr() { return m_d3dShaderResourceView.Get(); };

		_Decl_value_prop_hinl1(m_d3dContext, Context3Ptr, Context3); // Get/Set D3D 11 Device Context
		_Decl_value_prop_hinl1(m_d3dDevice, Device3Ptr, Device3); // Get/Set D3D 11 Device

		_Decl_value_prop_hinl2(m_viewport, D3D11_VIEWPORT, Viewport);
		_Decl_value_prop_hinl1(m_height, float32, Height);
		_Decl_value_prop_hinl1(m_width, float32, Width);

	public:

		BasicRenderTarget(_No_args_);
		void Initialize(_No_args_);
		void CreateWindowSizeDependentResources(_No_args_);
		void CreateDeviceIndependentResources(_No_args_);
		void UpdateForWindowSizeChange(_No_args_);
		void CreateDeviceResources(_No_args_);

	};
};